home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-01 | 3.7 KB | 120 lines | [TEXT/MPS ] |
- After E.T.O. #20 was buttoned up we found a couple of problems in the Framework library
- of MacApp. These problems involve two member functions of TDispatcher. To make the
- change to the source file open the file:
-
- Target "{macapp}Libraries:Framework:Sources:UDispatcher.cp"
-
- The two functions to be replaced are:
-
- TDispatcher::GetDocumentByIndex
- TDispatcher::GetContainedObject
-
- You should be able to find the first routine by executing the following MPW script:
-
- find •
- find /TDocument∂* TDispatcher::GetDocumentByIndex/
- find /∂{/
- matchit -c -h
- find §:/∂n/:\TDocument∂* TDispatcher::GetDocumentByIndex\
-
- You can then replace the selected code with the replacement code provided below.
-
- To find the second routine by executing the following MPW script:
-
- find •
- find /MScriptableObject∂* TDispatcher::GetContainedObject/
- find /∂{/
- matchit -c -h
- find §:/∂n/:\MScriptableObject∂* TDispatcher::GetContainedObject\
-
- You can then replace the selected code with the other replacement code provided below.
-
- //----------------------------------------------------------------------------------------
- // TDispatcher::GetDocumentByIndex:
- //----------------------------------------------------------------------------------------
- #pragma segment MAScriptingRes
-
- TDocument* TDispatcher::GetDocumentByIndex(DescType desiredType,
- short desiredIndex)
- {
- // Go through the window list and count to the Nth window associated with a document
- // of the desired type. Only count the first window for each document just
- // in case a document has more than one window.
-
- TWindow* aWindow = GetFrontWindow();
- TDocument* aDocument = NULL;
- short documentsSeen = 0;
- if (aWindow)
- {
- // Make a list for all of the documents we find until we find the one we want.
- TList* aDocList = ::NewList();
- WindowRef aWindowRef = aWindow->fWMgrWindow;
-
- while (aWindowRef && (documentsSeen < desiredIndex))
- {
- aWindow = WMgrToWindow(aWindowRef);
- if (aWindow)
- {
- aDocument = aWindow->fDocument;
- if (aDocument && (aDocument->GetOMClass() == desiredType))
- {
- // See if this document is already in the list.
- if (!aDocList->GetIdentityItemNo(aDocument))
- {
- ++documentsSeen;
- aDocList->InsertLast(aDocument);
- }
- }
- }
- aWindowRef = GetNextWindow(aWindowRef);
- }
- aDocList->Free();
- }
- return (documentsSeen == desiredIndex) ? aDocument : NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // TDispatcher::GetContainedObject:
- //----------------------------------------------------------------------------------------
- #pragma segment OSLDispatchRes
-
- MScriptableObject* TDispatcher::GetContainedObject(DescType desiredType,
- DescType selectionForm,
- const CAEDesc& selectionData)
- {
- MScriptableObject * result = NULL;
-
- if (desiredType == cFile)
- {
- // When you script 'file "Macintosh HD:My File"' AppleScript will
- // give the app a pathname and expect a file object in return.
- TFile * resultFile = DoMakeFile(cOpen);
- CStr255 thePathName;
- selectionData.GetString(thePathName);
- resultFile->SpecifyWithTrio(0, 0, (CStr63 &)thePathName);
- TOSADispatcher::fgDispatcher->AddTemporaryToken(resultFile);
-
- result = resultFile;
- }
- else if (IsDocumentClass(desiredType) && selectionForm == formName)
- {
- // We know we're going after a document with a
- // specific name so just scan the document list.
- CStr255 theDocName;
- selectionData.GetString(theDocName);
-
- CNoGhostDocsIterator iter(this);
- while (TDocument * aDocument = iter++)
- if ((aDocument->GetOMClass() == desiredType) && (aDocument->fTitle == theDocName))
- {
- result = aDocument;
- break;
- }
- }
- else
- result = MScriptableObject::GetContainedObject(desiredType, selectionForm, selectionData);
-
- return result;
- }
-
-